package com.itheima.stargraph.controller;

import com.itheima.stargraph.dto.common.Result;
import com.itheima.stargraph.dto.request.UserLoginReqDTO;
import com.itheima.stargraph.dto.respone.UserLoginResDTO;
import com.itheima.stargraph.service.UserService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户控制层
 *
 * @Author mr.zhang
 * Date 2025/6/9 11:33
 */
@RestController
@RequestMapping("/api/1.0/user")
public class UserController {
    @Autowired
    private UserService userService;


    /**
     * 用户登录
     */
    @PostMapping ("/login")
    public Result<UserLoginResDTO> login(@RequestBody @Valid UserLoginReqDTO dto){
        UserLoginResDTO resultDto = userService.login(dto);
        return Result.ok(resultDto);
    }
}
